/*    */ package com.zimbra.cs.dav.property;
/*    */ 
/*    */ import com.zimbra.cs.dav.DavContext;
/*    */ import com.zimbra.cs.dav.DavElements;
/*    */ import com.zimbra.cs.dav.LockMgr.Lock;
/*    */ import java.util.HashSet;
/*    */ import org.dom4j.Element;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class LockDiscovery
/*    */   extends ResourceProperty
/*    */ {
/*    */   private HashSet<LockMgr.Lock> mLocks;
/*    */   
/*    */   public LockDiscovery()
/*    */   {
/* 39 */     super(DavElements.E_LOCKDISCOVERY);
/* 40 */     setProtected(true);
/* 41 */     this.mLocks = new HashSet();
/*    */   }
/*    */   
/*    */   public LockDiscovery(LockMgr.Lock lock) {
/* 45 */     this();
/* 46 */     addLock(lock);
/*    */   }
/*    */   
/*    */   public Element toElement(DavContext ctxt, Element parent, boolean nameOnly) {
/* 50 */     Element activelock = super.toElement(ctxt, parent, true);
/* 51 */     if (nameOnly) {
/* 52 */       return activelock;
/*    */     }
/* 54 */     for (LockMgr.Lock l : this.mLocks) {
/* 55 */       Element lock = activelock.addElement(DavElements.E_ACTIVELOCK);
/* 56 */       Element el = lock.addElement(DavElements.E_LOCKTYPE);
/* 57 */       switch (l.type) {
/*    */       case write: 
/* 59 */         el.addElement(DavElements.E_WRITE);
/*    */       }
/*    */       
/* 62 */       el = lock.addElement(DavElements.E_LOCKSCOPE);
/* 63 */       switch (l.scope) {
/*    */       case shared: 
/* 65 */         el.addElement(DavElements.E_SHARED);
/* 66 */         break;
/*    */       case exclusive: 
/* 68 */         el.addElement(DavElements.E_EXCLUSIVE);
/*    */       }
/*    */       
/*    */       
/* 72 */       lock.addElement(DavElements.E_DEPTH).setText(l.depth);
/* 73 */       lock.addElement(DavElements.E_TIMEOUT).setText(l.getTimeoutStr());
/* 74 */       if (l.owner != null)
/* 75 */         lock.addElement(DavElements.E_OWNER).addElement(DavElements.E_HREF).setText(l.owner);
/* 76 */       lock.addElement(DavElements.E_LOCKTOKEN).addElement(DavElements.E_HREF).setText(l.token);
/*    */     }
/* 78 */     return activelock;
/*    */   }
/*    */   
/*    */   public void addLock(LockMgr.Lock l) {
/* 82 */     this.mLocks.add(l);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/property/LockDiscovery.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */